<template>
  <a-modal
    :visible="visible"
    title="成绩修改"
    :width="400"
    @cancel="() => { $emit('cancel') }"
    @ok="submit"
  >
    <a-form :form="form" style="margin-top: 10px">
      <a-row>
          <a-form-item
            label="成绩"
            :labelCol="{span: 4,offset: 1}"
            :wrapperCol="{span: 8, offset: 1}"
          >
            <a-input v-if="xs.cjlxm == '01'" v-model="kscj"/>
            <a-select :getPopupContainer="trigger => trigger.parentNode" style="min-width: 100px" v-else-if="xs.cjlxm == '02'" v-model="kscj">
                <a-select-option value="A">A</a-select-option>
                <a-select-option value="B">B</a-select-option>
                <a-select-option value="C">C</a-select-option>
                <a-select-option value="D">D</a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item
            label="备注"
            :labelCol="{span: 4,offset: 1}"
            :wrapperCol="{span: 8, offset: 1}"
          >
            <a-select allowClear style="min-width: 100px" v-model="note">
              <a-select-option v-for="i in TYPE0519" :key="i.id" :value="i.name">{{ i.name }}</a-select-option>
            </a-select>
          </a-form-item>
      </a-row>
    </a-form>
  </a-modal>
</template>

<script>
import { mapState } from 'vuex'


export default {
  props: {
    visible: Boolean,
    xs: Object
  },
  data () {
    return {
      kscj: '',
      note: ''
    }
  },
  computed: {
    ...mapState({
      TYPE0519: state => state.app['TYPE0519'],
    })
  },
  beforeCreate () {
    this.form = this.$form.createForm(this)
    this.$store.dispatch('app/setDictionary', 'TYPE0519')
  },
  methods: {
    submit(){
      console.log(this.xs)
      if (!String(this.kscj) && !this.note) {
        this.$message.warn('请输入完整的成绩，成绩为空时备注必填')
      } else {
        this.$api.cultivate.scoreDrcjUpdate({
          updateList: [{
            cjksxsmdId: this.xs.id,
            score: this.kscj,
            note: this.note
          }]
        }).then(res => {
          this.$message.success(res.msg)
          this.$emit('cancel')
          this.$emit('refresh')
        })
      }
    }
  }
}
</script>

<style>

</style>
